#!/bin/ksh

LOGIN=$1
SH_DIR=$2
UP_DIR=$3
UP_FILE=$4
BUSINESS=$5

sqlplus -s $LOGIN<<!
DELETE FROM ccs.ccs_ams_tmp_abnormal_usage;
COMMIT;
!

cat > $UP_DIR/ctl/Upload_AccountList.ctl<<!
LOAD DATA
INFILE '$UP_DIR/$UP_FILE'
APPEND INTO TABLE CCS.CCS_AMS_TMP_ABNORMAL_USAGE
TRAILING NULLCOLS
(
BUSINESS_TYPE            CONSTANT              '$BUSINESS',
ACCOUNT_NO               POSITION(001:008)     CHAR                  "TRIM(:ACCOUNT_NO)"
)
!
cd $UP_DIR/
/usr/local/bin/dos2unix $UP_FILE
sqlldr $LOGIN \
control=$UP_DIR/ctl/Upload_AccountList.ctl bad=$UP_DIR/bad/Upload_AccountList.bad \
log=$UP_DIR/log/Upload_AccountList.log >> $UP_DIR/log/Upload_AccountList.log

